package com.sleep.ws.client.core;

import com.alibaba.fastjson.JSON;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Sleep-6000
 * @date 2024/3/8
 */
public class PushMessageTemplate {
    public static String generateTemplate(String topic, Object data, String token) {
        // 拼装消息Map
        Map<String, Object> msgTemplateMap = new HashMap<>(5);
        msgTemplateMap.put("time", new Date());
        msgTemplateMap.put("data", data);
        msgTemplateMap.put("topic", topic);
        msgTemplateMap.put("token", token);
        msgTemplateMap.put("flag", "push");
        return JSON.toJSONString(msgTemplateMap);
    }
}
